package com.jida.tijian.controller;

import com.jida.tijian.domain.Users;
import com.jida.tijian.dto.ResponseObject;
import com.jida.tijian.service.UsersService;
import com.jida.tijian.service.UsersServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 处理用户模块请求的控制器
 */
@RestController //@Controller+@ResponseBody
public class UserController {


    @Autowired
    UsersService userService;//声明接口，不能声明实现类
    /**
     * 定义处理登录请求的方法
     */
    /* public Users login(Users users){
        Users u=null;

        //调用service

        return u;
    }   这样写是错误的，愿意是前后端沟通效果低下
    */
    @RequestMapping("/login") //http://localhost:8080/login
    public ResponseObject<Users> login(@RequestBody Users users){    //json对象-->java对象
        System.out.println("users:"+users.getUserId()+","+users.getPassword());
        //controller--->service----->Mapper
        //1.根据手机号查询用户，看有没有 2.根据密码比对用户 看密码对不对


        //Users u=users;

        //ResponseObject<Users> responseObject=new ResponseObject<>(200,"成功",u);
        ResponseObject<Users> responseObject=userService.login(users);
        /*
        response:
        status:
        data:
         */
            /*
            responseObject:
            status:200
            desc:成功
            data:user
             */


        return responseObject;
    }
    /**
     * 定义处理注册请求的方法
     */

    /**
     * 定义处理修改密码请求的方法
     */

    /**
     * 定义处理快捷登录请求的方法
     */
}
